class BlackDeathFirePoint extends NavigationPoint
	placeable;
	
var() bool bEnabled; //Is the fire currently on?
var() float radius; //How far this fire can reach to affect Pawns
var() float Rate; //Rate that the point checks for pawns close to it to ignite. Also determines how offten damage is dealt while standing in actor.
var() bool bDamage; //Do we deal damage when in the fire? If false, simply ignited without damageing
var() bool bDamageWhileOnFire; //Do we deal damage if the pawn is on fire or not? If false ignited pawns are ignored by firepoint
var() int DamageAmount; //How much damage gets dealt


simulated function InitializeFire() //Can be used to set fire effects if we want this to be a visible actor
{
	//SetFireEffect();
}

simulated event SetInitialState()
{
	bScriptInitialized = true;
	if (!bEnabled)
	{
		GotoState('Disabled');
	}
	else
	{
		Super.SetInitialState();
	}
}

/*
simulated function SetFireEffect()
{
	if ( PickupMesh != None )
	{
		if (PickupMesh.HiddenGame)
		{
			PickupMesh.SetHidden(false);
		}
	}
}*/

function Reset()
{
	if(bEnabled)
		GotoState('Lit');
	else
		GotoState('Disabled');
	Super.Reset();
}

function AffectPawn( BlackDeathPawn BDP )
{
	`log("Pawn found, afffecting");
	IgnitePawn(BDP);
	FireDamage(BDP);
}

function ignitePawn( BlackDeathPawn BDP )
{
	if(BDP != none)
	{
		BDP.ignite();
	}
}

function FireDamage(BlackDeathPawn BDP)
{
	if(bDamage)
	{
		if(!BDP.bOnFire || bDamageWhileOnFire)
		{
			BDP.TakeDamage(DamageAmount, none, Location, vect(0,0,0), class'DmgType_Crushed');
		}
	}
}

auto state Lit
{
	event BeginState(Name PreviousStateName)
	{
		SetTimer(Rate, true, 'RecheckValidTouch');
	}

	function bool ValidTouch( BlackDeathPawn Other )
	{
		// make sure its a live player
		if (Other == None)
		{
			return false;
		}
		else if (Other.Controller == None)
		{
			// re-check later in case this Pawn is in the middle of spawning, exiting a vehicle, etc
			// and will have a Controller shortly
			return false;
		}
		// make sure not touching through wall
		else if ( !FastTrace(Other.Location, Location) )
		{
			return false;
		}
		
		return true;
	}

	/**
	Pickup was touched through a wall.  Check to see if touching pawn is no longer obstructed
	*/
	function RecheckValidTouch()
	{
		CheckTouching();
	}

	// When touched by an actor.
	event Lit( BlackDeathPawn BDP)
	{
		if( BDP != None && ValidTouch(BDP) )
		{
			AffectPawn(BDP);
 		}
	}

	// Make sure no pawn already touching (while touch was disabled in sleep).
	function CheckTouching()
	{
		local BlackDeathPawn BDP;

		ForEach CollidingActors(class'BlackDeathPawn', BDP, radius, location)
			Lit(BDP);
	}
	
	event EndState(Name NextStateName)
	{
		ClearTimer('RecheckValidTouch');
	}

Begin:
	CheckTouching();
}

State Disabled
{
}

function OnToggle(SeqAct_Toggle inAction)//controls the kismet Toggle node input
{
	if (inAction.InputLinks[0].bHasImpulse)
	{
		bEnabled = true;
		goToState('Lit');
	}
	else if (inAction.InputLinks[1].bHasImpulse)
	{
		bEnabled = false;
		goToState('Disabled');
	}
	else if (inAction.InputLinks[2].bHasImpulse)
	{
		bEnabled = !bEnabled;
	}
	if(bEnabled)
	{
		goToState('Lit');
	}
	else
	{
		goToState('Disabled');
	}
	WorldInfo.Game.NotifyNavigationChanged(self);

	bShouldSaveForCheckpoint = true;
}

defaultproperties
{
	TickGroup=TG_DuringAsyncWork
	
	//Components.Remove(Sprite)
	
	bEnabled = true
	radius = 100
	rate = 0.2
	DamageAmount = 1
	bDamageWhileOnFire = true
	bDamage = true

	bCollideWhenPlacing=False
	bHiddenEd=false
	bStatic=false
	bNoDelete=true
	RemoteRole=ROLE_SimulatedProxy
	bAlwaysRelevant=true
	bCollideActors=true
	bCollideWorld=false
	bBlockActors=false
	bIgnoreEncroachers=true
	bHidden=false
	NetUpdateFrequency=1.0
	//SupportedEvents.Add(class'SeqEvent_PickupStatusChange')
}